Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
PaintRegionBuffer(Graphics,Rectangle,Rectangle,Rectangle,Rectangle,Byte[],Int32,Int32,Int32,RasterPaintProperties) Method
See Also  Example
Leadtools Namespace > RasterImage Class > PaintRegionBuffer Method : PaintRegionBuffer(Graphics,Rectangle,Rectangle,Rectangle,Rectangle,Byte[],Int32,Int32,Int32,RasterPaintProperties) Method



graphics
The destination Graphics object where the image data will be displayed.
srcRect

A Rectangle object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

srcClipRect

A Rectangle object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

destRect

A Rectangle object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Rectangle object.

destClipRect

A Rectangle object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the Graphics object. You can pass Rectangle.Empty to use the default, which matches the Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

buffer
The buffer that contains the image data to paint
bufferOffset
Offset into buffer where the data starts.
row
The first row to paint. The painted portion of any row may be limited by the rectangle parameters.
count

The number of rows to paint. The painted portion of any row may be limited by the rectangle parameters.

If the image data in buffer is compressed 1-bit data, you can specify the number of lines as a negative value (-lines), as explained in Speeding Up 1-Bit Documents.

properties
Options for the display.
Paints image region data from a buffer into a Graphics object.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub PaintRegionBuffer( _
   ByVal graphics As Graphics, _
   ByVal srcRect As Rectangle, _
   ByVal srcClipRect As Rectangle, _
   ByVal destRect As Rectangle, _
   ByVal destClipRect As Rectangle, _
   ByVal buffer() As Byte, _
   ByVal bufferOffset As Integer, _
   ByVal row As Integer, _
   ByVal count As Integer, _
   ByVal properties As RasterPaintProperties _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim graphics As Graphics
Dim srcRect As Rectangle
Dim srcClipRect As Rectangle
Dim destRect As Rectangle
Dim destClipRect As Rectangle
Dim buffer() As Byte
Dim bufferOffset As Integer
Dim row As Integer
Dim count As Integer
Dim properties As RasterPaintProperties
 
instance.PaintRegionBuffer(graphics, srcRect, srcClipRect, destRect, destClipRect, buffer, bufferOffset, row, count, properties)
C# 
public void PaintRegionBuffer( 
   Graphics graphics,
   Rectangle srcRect,
   Rectangle srcClipRect,
   Rectangle destRect,
   Rectangle destClipRect,
   byte[] buffer,
   int bufferOffset,
   int row,
   int count,
   RasterPaintProperties properties
)
C++/CLI 
public:
void PaintRegionBuffer( 
   Graphics graphics,
   Rectangle srcRect,
   Rectangle srcClipRect,
   Rectangle destRect,
   Rectangle destClipRect,
   array<byte>^ buffer,
   int bufferOffset,
   int row,
   int count,
   RasterPaintProperties properties
) 

Parameters

graphics
The destination Graphics object where the image data will be displayed.
srcRect

A Rectangle object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

srcClipRect

A Rectangle object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

destRect

A Rectangle object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Rectangle object.

destClipRect

A Rectangle object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the Graphics object. You can pass Rectangle.Empty to use the default, which matches the Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

buffer
The buffer that contains the image data to paint
bufferOffset
Offset into buffer where the data starts.
row
The first row to paint. The painted portion of any row may be limited by the rectangle parameters.
count

The number of rows to paint. The painted portion of any row may be limited by the rectangle parameters.

If the image data in buffer is compressed 1-bit data, you can specify the number of lines as a negative value (-lines), as explained in Speeding Up 1-Bit Documents.

properties
Options for the display.

Example

Visual BasicCopy Code
Public Sub PaintRegionBufferExample()
   Dim f As PaintRegionBufferForm = New PaintRegionBufferForm()
   f.ShowDialog()
End Sub

Private Class PaintRegionBufferForm : Inherits Form
   Private image As RasterImage

   Public Sub New()
      ' Load the image
      RasterCodecs.Startup()
      Dim codecs As RasterCodecs = New RasterCodecs()

      Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"
      image = codecs.Load(srcFileName)

      ' add a region to the image
      image.AddEllipseToRegion(RasterRegionXForm.Default, New Rectangle(image.Width \ 4, image.Height \ 4, image.Width \ 2, image.Height \ 2), RasterRegionCombineMode.Set)

      Text = "PaintRegionBuffer Example"
   End Sub

   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      ' Clean up
      If disposing Then
         image.Dispose()
         RasterCodecs.Shutdown()
      End If

      MyBase.Dispose(disposing)
   End Sub

   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
      ' Draw the image fit and center on this form
      Dim destRect As Rectangle = RasterImage.CalculatePaintModeRectangle(image.ImageWidth, image.ImageHeight, ClientRectangle, RasterPaintSizeMode.Fit, RasterPaintAlignMode.Center, RasterPaintAlignMode.Center)

      Dim buffer As Byte() = New Byte(image.BytesPerLine - 1) {}

      If image.IsGlobalMemory Then
         image.Access()
      End If
      Dim row As Integer = 0
      Do While row < image.Height
         image.GetRow(row, buffer, 0, image.BytesPerLine)
         image.PaintRegionBuffer(e.Graphics, Rectangle.Empty, Rectangle.Empty, destRect, Rectangle.Empty, buffer, 0, row, 1, RasterPaintProperties.Default)
         Thread.Sleep(20)
         row += 1
      Loop
      If image.IsGlobalMemory Then
         image.Release()
      End If

      MyBase.OnPaint(e)
   End Sub
End Class
C#Copy Code
public void PaintRegionBufferExample() 

   PaintRegionBufferForm f = new PaintRegionBufferForm(); 
   f.ShowDialog(); 

 
class PaintRegionBufferForm : Form 

   RasterImage image; 
 
   public PaintRegionBufferForm() 
   { 
      // Load the image 
      RasterCodecs.Startup(); 
      RasterCodecs codecs = new RasterCodecs(); 
 
      string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"; 
      image = codecs.Load(srcFileName); 
 
      // add a region to the image 
      image.AddEllipseToRegion(RasterRegionXForm.Default, new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2), RasterRegionCombineMode.Set); 
 
      Text = "PaintRegionBuffer Example"; 
   } 
 
   protected override void Dispose(bool disposing) 
   { 
      // Clean up 
      if(disposing) 
      { 
         image.Dispose(); 
         RasterCodecs.Shutdown(); 
      } 
 
      base.Dispose(disposing); 
   } 
 
   protected override void OnPaint(PaintEventArgs e) 
   { 
      // Draw the image fit and center on this form 
      Rectangle destRect = RasterImage.CalculatePaintModeRectangle( 
         image.ImageWidth, 
         image.ImageHeight, 
         ClientRectangle, 
         RasterPaintSizeMode.Fit, 
         RasterPaintAlignMode.Center, 
         RasterPaintAlignMode.Center); 
 
      byte[] buffer = new byte[image.BytesPerLine]; 
 
      if(image.IsGlobalMemory) 
         image.Access(); 
      for(int row = 0; row < image.Height; row++) 
      { 
         image.GetRow(row, buffer, 0, image.BytesPerLine); 
         image.PaintRegionBuffer(e.Graphics, Rectangle.Empty, Rectangle.Empty, destRect, Rectangle.Empty, buffer, 0, row, 1, RasterPaintProperties.Default); 
         Thread.Sleep(20); 
      } 
      if(image.IsGlobalMemory) 
         image.Release(); 
 
      base.OnPaint(e); 
   } 
}

Remarks

This method works the same as PaintBuffer, except that only the image region is painted

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also